package
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.net.Socket;

	public class ErrorExample extends Sprite
	{
		private var targetServer:String="www.kingda.org";
		private var port:uint=1234;

		public function ErrorExample()
		{
			Init();
		}

		private function Init():void
		{
			// 创建BitmapData对象
			var bmd1:BitmapData=new BitmapData(200, 200, true, 0xFFCCFFCC);
			// 复制bmd1
			var bmd2:BitmapData=bmd1.clone();
			// 创建Bitmap对象
			var bm1:Bitmap=new Bitmap(bmd1);
			addChild(bm1);
			var bm2:Bitmap=new Bitmap(bmd2);
			addChild(bm2);

			// 设置位置
			bm1.x=50;
			bm1.y=100;
			bm2.x=260;
			bm2.y=100;

			goOn();
		}

		private function goOn():void
		{
			try
			{
				var socket:Socket=new Socket();
				socket.connect(targetServer, port);
				//注意，一旦异常发生后，下面这句trace是不会执行到的
				trace("try end");
			}
			catch (e:SecurityError)
			{
				trace(e);
			}
			finally
			{
				trace("finally");
			}
		}
	}
}
